package com.example;
import javafx.collections.ObservableList;
import javafx.embed.swing.SwingFXUtils;
import javafx.scene.image.*;
import org.opencv.core.Mat;
import java.util.*;

/**
 * <p>拼接控制器</p>
 *
 * @author dc
 * @date 2025-09-25
 **/
public class ImageStitchingController {

    // 执行拼接操作
    public WritableImage stitchImages(List<WritableImage> imageList) {
        if (imageList == null || imageList.isEmpty())  {
            return null;
        }

        // 转换为OpenCV Mat对象
        List<Mat> mats = new ArrayList<>();
        for (WritableImage img : imageList) {
            mats.add(ImageConverter.writeableImageToMat(img));
        }

        // 执行拼接 
        Mat resultMat = ImageStitcher.stitchImages(mats);

        // 转换为JavaFX Image 
        return ImageConverter.matToWriteableImage(resultMat);
    }
    
}